﻿using System;
using System.Text;

namespace Activity.Helper
{
    public class Base64
    {
        /// <summary>
        /// 加密
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public static string Base64Encode(string input)
        {
            byte[] bytes = Encoding.Default.GetBytes(input);
            string str = Convert.ToBase64String(bytes);
            str = str.Replace("+", " ");
            return str;
        }

        /// <summary>
        /// 解密
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public static string Base64Decode(string input)
        {
            input = input.Replace(" ", "+");
            byte[] outputb = Convert.FromBase64String(input);
            string orgStr = Encoding.Default.GetString(outputb);
            return orgStr;
        }
    }
}
